package main

import (
	"fmt"
	"time"
)

func main() {
	now := time.Now()
	fmt.Println(now) // 2023-01-18 00:57:21.1727255 +0800 CST m=+0.008083801
	t := time.Date(2023, 1, 18, 0, 57, 21, 0, time.UTC)
	t2 := time.Date(2023, 1, 18, 0, 57, 21, 0, time.UTC)
	fmt.Println(t)
	fmt.Println(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute())
	fmt.Println(t.Format("2006-01-02 15:04:05")) //按照格式打印
	diff := t2.Sub(t)                            //时间相减
	fmt.Println(diff)
	fmt.Println(diff.Minutes(), diff.Seconds())
	t3, err := time.Parse("2006-01-02 15:04:05", "2023-01-18 00:57:21")
	if err != nil {
		panic(err)
	}
	fmt.Println(t3 == t)
	fmt.Println(now.Unix()) //时间戳
}
